package Game;

public class IndexCounter {
	private int Index;
	private int indexes;
	private long beginTime=System.currentTimeMillis();
	private long cumTime=beginTime;
	private long timeDiff;
	private long totalTime;
	private long speed;
	public IndexCounter(int Indexes,long speed){
		speed=speed*100000;
		this.speed=speed*10000000;
		this.indexes=Indexes;
	}
	public void setCounter(int Indexes,long speed){
		speed=speed*100000;
		this.speed=speed*10000000;
		this.indexes=Indexes;
	}
	public void setIndexes(int Indexes){
		this.indexes=indexes;
	}
	public void setSpeed(long speed){
		speed=speed*100000;
		this.speed=speed*10000000;
	}
	public void Counter(){
		timeDiff=System.currentTimeMillis()-cumTime;
		cumTime=timeDiff;
		totalTime+=timeDiff;
		
		if(totalTime>=speed*(Index+1)){
			Index++;
		}
		if(totalTime>=(speed*indexes)){
			totalTime=0;
			Index=0;
		}
	}
	public int getIndex(){
		if(Index>=indexes)
			Index=indexes;
		return Index;
	}
}
